/*
 * @Descripttion: 医生开药
 * @version: 1.0
 * @Author: 自由如风
 * @Date: 2021-04-28 20:00:55
 * @LastEditors: 自由如风
 * @LastEditTime: 2021-04-28 20:56:38
 */

const DB = require("../../lib/DB");
const { Success } = require("../../lib/Response");

module.exports = async function (ctx, next) {
    const { prescription_id, prescription_date, medicine_lib_id, doctor_medicine_lib_id, drug_name, dose, amount, memo } = ctx.request.body;
    try {
        const prescription_sheet = await DB.models.prescription_sheet.create({ prescription_id, prescription_date, medicine_lib_id, doctor_medicine_lib_id, drug_name, dose, amount, memo })
        ctx.body = new Success(prescription_sheet.toJSON())
        await next();
    } catch (e) {
        console.error(e)
        throw new Error("开药失败")
    }
}
